﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.Domains.ScratchTheFat;

namespace Butcher.winform.EnterpriseForms.CheckReport
{
    public partial class ApproachInspectionListAdded : Form
    {
        public ApproachInspectionListAdded()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            单据日期 = new Label();
            label1 = new Label();
            label2 = new Label();
            label3 = new Label();
            label4 = new Label();
            label5 = new Label();
            label6 = new Label();
            label7 = new Label();
            label8 = new Label();
            textBox2 = new TextBox();
            textBox6 = new TextBox();
            textBox7 = new TextBox();
            textBox8 = new TextBox();
            textBox9 = new TextBox();
            textBox10 = new TextBox();
            textBox11 = new TextBox();
            textBox3 = new TextBox();
            button1 = new Button();
            dateTimePicker1 = new DateTimePicker();
            SuspendLayout();
            // 
            // 单据日期
            // 
            单据日期.AutoSize = true;
            单据日期.Location = new Point(331, 110);
            单据日期.Name = "单据日期";
            单据日期.Size = new Size(82, 24);
            单据日期.TabIndex = 0;
            单据日期.Text = "单据日期";
            单据日期.Click += label1_Click;
            // 
            // label1
            // 
            label1.AutoSize = true;
            label1.Location = new Point(332, 190);
            label1.Name = "label1";
            label1.Size = new Size(82, 24);
            label1.TabIndex = 2;
            label1.Text = "检测类型";
            // 
            // label2
            // 
            label2.AutoSize = true;
            label2.Location = new Point(332, 285);
            label2.Name = "label2";
            label2.Size = new Size(64, 24);
            label2.TabIndex = 3;
            label2.Text = "单据号";
            // 
            // label3
            // 
            label3.AutoSize = true;
            label3.Location = new Point(331, 385);
            label3.Name = "label3";
            label3.Size = new Size(82, 24);
            label3.TabIndex = 4;
            label3.Text = "检测类型";
            // 
            // label4
            // 
            label4.AutoSize = true;
            label4.Location = new Point(331, 490);
            label4.Name = "label4";
            label4.Size = new Size(82, 24);
            label4.TabIndex = 5;
            label4.Text = "检测商品";
            // 
            // label5
            // 
            label5.AutoSize = true;
            label5.Location = new Point(332, 554);
            label5.Name = "label5";
            label5.Size = new Size(82, 24);
            label5.TabIndex = 6;
            label5.Text = "商品批号";
            // 
            // label6
            // 
            label6.AutoSize = true;
            label6.Location = new Point(332, 632);
            label6.Name = "label6";
            label6.Size = new Size(82, 24);
            label6.TabIndex = 7;
            label6.Text = "检测类别";
            label6.Click += label6_Click;
            // 
            // label7
            // 
            label7.AutoSize = true;
            label7.Location = new Point(349, 780);
            label7.Name = "label7";
            label7.Size = new Size(64, 24);
            label7.TabIndex = 8;
            label7.Text = "制单人";
            label7.Click += label7_Click;
            // 
            // label8
            // 
            label8.AutoSize = true;
            label8.Location = new Point(331, 697);
            label8.Name = "label8";
            label8.Size = new Size(82, 24);
            label8.TabIndex = 9;
            label8.Text = "审核状态";
            // 
            // textBox2
            // 
            textBox2.Location = new Point(587, 484);
            textBox2.Name = "textBox2";
            textBox2.Size = new Size(150, 30);
            textBox2.TabIndex = 10;
            // 
            // textBox6
            // 
            textBox6.Location = new Point(587, 626);
            textBox6.Name = "textBox6";
            textBox6.Size = new Size(150, 30);
            textBox6.TabIndex = 14;
            // 
            // textBox7
            // 
            textBox7.Location = new Point(587, 691);
            textBox7.Name = "textBox7";
            textBox7.Size = new Size(150, 30);
            textBox7.TabIndex = 15;
            // 
            // textBox8
            // 
            textBox8.Location = new Point(587, 774);
            textBox8.Name = "textBox8";
            textBox8.Size = new Size(150, 30);
            textBox8.TabIndex = 16;
            // 
            // textBox9
            // 
            textBox9.Location = new Point(587, 379);
            textBox9.Name = "textBox9";
            textBox9.Size = new Size(150, 30);
            textBox9.TabIndex = 17;
            // 
            // textBox10
            // 
            textBox10.Location = new Point(587, 279);
            textBox10.Name = "textBox10";
            textBox10.Size = new Size(150, 30);
            textBox10.TabIndex = 18;
            // 
            // textBox11
            // 
            textBox11.Location = new Point(587, 190);
            textBox11.Name = "textBox11";
            textBox11.Size = new Size(150, 30);
            textBox11.TabIndex = 19;
            // 
            // textBox3
            // 
            textBox3.Location = new Point(587, 548);
            textBox3.Name = "textBox3";
            textBox3.Size = new Size(150, 30);
            textBox3.TabIndex = 20;
            // 
            // button1
            // 
            button1.Location = new Point(455, 894);
            button1.Name = "button1";
            button1.Size = new Size(112, 34);
            button1.TabIndex = 21;
            button1.Text = "添加";
            button1.UseVisualStyleBackColor = true;
            button1.Click += button1_Click;
            // 
            // dateTimePicker1
            // 
            dateTimePicker1.Location = new Point(587, 104);
            dateTimePicker1.Name = "dateTimePicker1";
            dateTimePicker1.Size = new Size(150, 30);
            dateTimePicker1.TabIndex = 22;
            // 
            // ApproachInspectionListAdded
            // 
            ClientSize = new Size(1423, 1049);
            Controls.Add(dateTimePicker1);
            Controls.Add(button1);
            Controls.Add(textBox3);
            Controls.Add(textBox11);
            Controls.Add(textBox10);
            Controls.Add(textBox9);
            Controls.Add(textBox8);
            Controls.Add(textBox7);
            Controls.Add(textBox6);
            Controls.Add(textBox2);
            Controls.Add(label8);
            Controls.Add(label7);
            Controls.Add(label6);
            Controls.Add(label5);
            Controls.Add(label4);
            Controls.Add(label3);
            Controls.Add(label2);
            Controls.Add(label1);
            Controls.Add(单据日期);
            Name = "ApproachInspectionListAdded";
            Text = "进场检验单添加";
            ResumeLayout(false);
            PerformLayout();
        }

        private Label 单据日期;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label label7;
        private Label label8;
        private TextBox textBox2;
        private TextBox textBox6;
        private TextBox textBox7;
        private TextBox textBox8;
        private TextBox textBox9;
        private TextBox textBox10;
        private TextBox textBox11;
        private TextBox textBox3;
        private DateTimePicker dateTimePicker1;
        private Button button1;

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string url = @"http://localhost:5229/api/Batch/ApproachInspectionCreate";
            HttpClient client = new HttpClient();
            ApproachInspectionSheet list1 = new ApproachInspectionSheet();
            list1.Approachid = 0;
            list1.receiptTime =Convert.ToDateTime(dateTimePicker1.Value);
            list1.PutStorageType = textBox11.Text;
            list1.PutStorageStash = textBox2.Text;
            list1.ShoppgingDesignation = Convert.ToInt32(textBox3.Text);
            list1.putDesNum = Convert.ToInt32(textBox11.Text);
            list1.PutNum =Convert.ToInt32(textBox7.Text);
            list1.ProductionlotNumber = textBox10.Text;
            list1.ProDuctionTime = DateTime.Now.ToString();
            list1.ProClassTissue = DateTime.Now.ToString();

            var content = new StringContent(JsonSerializer.Serialize<ApproachInspectionSheet>(list1), Encoding.UTF8);
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject josnresult = JObject.Parse(result);
            var results = josnresult["code"];
            if(results!=null)
            {
                MessageBox.Show("添加成功");

            }
        }
    }
}
